﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System;

public class Card : MonoBehaviour
{
    public int cardValue;
    public bool hideCard;
    private int cardUINum;
    public  Image img;

    void Awake()
    {
            img = GetComponent<Image>();
    }

    private void GetCardUINum(int value)
    {
        if (value <= 52)
        {
            cardUINum = value;
        }
        else if (value > 56 && value <= 60)
        {
            cardUINum = value - 56;
        }
        else if (value == 61 || value == 62)
        {
            cardUINum = value - 8;
        }
    }

    public void LoadValueSprite()
    {
        GetCardUINum(cardValue);
        Debug.Log(cardUINum);
        img.sprite = Resources.Load<Sprite>("Card/"+cardUINum);
    }

    public void LoadBackSprite()
    {
        img.sprite = Resources.Load<Sprite>("Card/back");
    }

    public void ShowCardTypeValue()
    {
        if (hideCard)
        {
            LoadValueSprite();
        }
    }

    public void ShowCardTypeBack()
    {
        if (hideCard)
        {
            LoadBackSprite();
        }
    }
}

